package com.myt.matp.gui;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;

public class UIImage extends UIWidget {

    private Image m_Image = null;

    protected UIImage(int id, GUI gui) {
	super(id, gui);
    }

    public int getType() {
	return UIWidget.IMAGE;
    }

    protected void resized() {
    }

    public final void load(String name) {
	try {
	    m_Image = Image.createImage(name);
	} catch (Exception e) {
	    m_Image = null;
	}
    }

    protected void paintUIWidget(MGraphics g) {

	if (m_Image != null) {
	    g.setClip(getViewX(), 
		      getViewY(), 
		      getViewWidth(),
		      getViewHeight());
	    g.drawImage(m_Image, 
			getViewX(), 
			getViewY(), 
			Graphics.BASELINE| Graphics.LEFT);
	}
    }

}